Added ProtocolHelper and some tests
[brmtron.git] / BrmTron Client / src / cz / brmlab / brmtron / client / EditOptions.java
blobe444b59a7dfeee5a5ab5618b9d62c777acea3391
1 package cz.brmlab.brmtron.client;
3 import android.app.Activity;
4 import android.content.SharedPreferences;
5 import android.content.SharedPreferences.Editor;
6 import android.os.Bundle;
7 import android.view.View;
8 import android.view.View.OnClickListener;
9 import android.widget.Button;
10 import android.widget.EditText;
12 public class EditOptions extends Activity {
14 SharedPreferences prefs;
15 EditText server, port;
17 @Override
18 protected void onCreate(Bundle savedInstanceState) {
19 super.onCreate(savedInstanceState);
20 setContentView(R.layout.edit_options);
22 prefs = getSharedPreferences(BrmTronClient.PREFS_FILE, MODE_PRIVATE);
24 server = (EditText) findViewById(R.id.edit_server);
25 port = (EditText) findViewById(R.id.edit_port);
26 Button confirmButton = (Button) findViewById(R.id.confirm);
28 loadOptions();
30 confirmButton.setOnClickListener(new OnClickListener() {
32 public void onClick(View v) {
33 setResult(RESULT_OK);
34 finish();
36 });
39 @Override
40 protected void onPause() {
41 super.onPause();
42 saveOptions();
45 @Override
46 protected void onResume() {
47 super.onResume();
48 loadOptions();
51 @Override
52 protected void onSaveInstanceState(Bundle outState) {
53 super.onSaveInstanceState(outState);
54 saveOptions();
57 private void saveOptions() {
58 Editor edit = prefs.edit();
59 edit.putString(BrmTronClient.PREFS_SERVER_KEY, server.getText().toString());
60 edit.putString(BrmTronClient.PREFS_PORT_KEY, port.getText().toString());
61 edit.commit();
64 private void loadOptions() {
65 server.setText(prefs.getString(BrmTronClient.PREFS_SERVER_KEY, ""));
66 port.setText(prefs.getString(BrmTronClient.PREFS_PORT_KEY, ""));